package com.yuexun.dhdoctor.module.my.presenter.impl;


import com.yuexun.dhdoctor.module.my.bean.MessageCountBean;
import com.yuexun.dhdoctor.module.my.model.IMyModel;
import com.yuexun.dhdoctor.module.my.presenter.IMyPresenter;
import com.yuexun.dhdoctor.module.my.ui.view.IMyView;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/11/30.
 */
public class MyPresenter implements IMyPresenter {
    private IMyView view;
    private IMyModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public MyPresenter(IMyModel model, IMyView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void getMessageCount(Map<String, String> praise) {
        model.getMessageCount(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<MessageCountBean>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
//                        ViewInject.toast("消息列表获取失败");
                    }

                    @Override
                    public void onNext(MessageCountBean messageCountBean) {
                        view.showMessageCount(messageCountBean);
                    }
                });
    }
}
